﻿<%@ Page Language="C#" Theme="SkinFile" MasterPageFile="~/MarterUsuarios.master" AutoEventWireup="true" CodeFile="juego.aspx.cs" Inherits="Juegos_juego" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Label1" runat="server" Text="Juego: "></asp:Label>
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br />
    <br />
    Apuesta:
    <asp:TextBox ID="apuesta" runat="server" Width="46px"></asp:TextBox>&nbsp;<asp:Button
        ID="Button1" runat="server" Text="Apostar" OnClick="Button1_Click" TabIndex="1" />
    &nbsp;&nbsp;
    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Salir" TabIndex="2" /><br />
    <br />
    <asp:Label ID="Resultado" runat="server"></asp:Label><br />
    <br />
    &nbsp;
    <div id="salaChat" style="width: 212px; height: 176px; border-right: blue thin solid; border-top: blue thin solid; border-left: blue thin solid; border-bottom: blue thin solid;">
    </div>

<script language="javascript" type="text/javascript">
    var XMLHttpRequestObject = false;     
    if (window.XMLHttpRequest) {
        XMLHttpRequestObject = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

function consultarChat(){
    
    if(XMLHttpRequestObject) {
        var date = new Date();
        var timestamp = date.getTime();
        var ruta="Chat.aspx?n="+timestamp;
        
        //alert("ruta: "+par1+" "+par2+" "+par3);
        XMLHttpRequestObject.open("GET", ruta);
        XMLHttpRequestObject.onreadystatechange = function(){
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
            
                var resp=XMLHttpRequestObject.responseText;
                //var capa=document.getElementById("ctl00_ContentPlaceHolder1_chat");
                var capa=document.getElementById("salaChat");
                capa.innerHTML=resp;
            }
            
        }
    }
    XMLHttpRequestObject.send(null);
} 

setInterval(consultarChat,1500);
    
function hablarChat(){
    var texto=document.getElementById("lineaChat").value;
    document.getElementById("lineaChat").value="";
    if(XMLHttpRequestObject) {
        var date = new Date();
        var timestamp = date.getTime();
        var ruta="EnviarLineaChat.aspx?texto="+texto+"&n="+timestamp;
        
        XMLHttpRequestObject.open("GET", ruta);
        /*XMLHttpRequestObject.onreadystatechange = function(){
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
            
                var resp=XMLHttpRequestObject.responseText;
                //var capa=document.getElementById("ctl00_ContentPlaceHolder1_chat");
                var capa=document.getElementById("salaChat");
                capa.innerHTML=resp;
            }
            
        }*/
    }
    XMLHttpRequestObject.send(null);
    function pulsar(evento){
        alert();
        if(evento.keyCode==13){
            alert(2);
            hablarChat();
            return false;
        }
    }
} 
</script>
    <!--form name="chat" action="" onsubmit="return false;"-->
    <input id="lineaChat" type="text"/>
    <input id="Button4" type="button" value="Enviar" onclick="hablarChat();"/>
    <!--/form-->
</asp:Content>

